package sythreeduixiang;
public class Teacher extends Person {
    private Course taughtCourse; // 所授课程
    // 子类构造方法：通过super()调用父类构造
    public Teacher(String teacherId, String name, String gender) {
        super(teacherId, name, gender); // 调用父类的构造方法
    }
    // 开设课程的方法
    public void openCourse(Course course) {
        this.taughtCourse = course;
        System.out.println(name + "老师开设了课程《" + course.getCourseName() + "》");
    }
    // 重写父类的printSchedule方法：打印教师课表
    public void printSchedule() {
        if (taughtCourse != null) {
            System.out.println("==========" + name + "老师的课表==========");
            super.printInfo(); 
            System.out.println("课程名称：" + taughtCourse.getCourseName());
            System.out.println("上课地点：" + taughtCourse.getLocation());
            System.out.println("上课时间：" + taughtCourse.getTime());
            System.out.println("=================================");
        } else {
            System.out.println(name + "老师未开设任何课程，课表为空");
        }
    }
    // Getter方法
    public Course getTaughtCourse() {
        return taughtCourse;
    }
}